//
//  HWDispatchGroup.h
//  OCDemo
//
//  Created by 李含文 on 2021/5/6.
/*
 /// 使用案例
 HWDispatchGroup *group = [HWDispatchGroup dispatchGroup];
 [group addAsyncTask:^(HWDispatchGroup * _Nonnull group) { // 添加任务1
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         NSLog(@"任务1");
         [group taskComplete]; // 任务1完成 标记
     });
 }];
 
 [group addAsyncTask:^(HWDispatchGroup * _Nonnull group) { // 添加任务2
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         NSLog(@"任务2");
         [group taskComplete]; // 任务2完成 标记
     });
 }];
 [group groupNotify:^{ // 完成所有任务监听
     NSLog(@"完成");
 }];
 */

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface HWDispatchGroup : NSObject

+ (HWDispatchGroup *)dispatchGroup;
/// 添加异步任务 注意:在任务完成后需要调用 - (void)taskComplete 方法 标记当前异步任务完成
- (void)addAsyncTask:(void(^)(HWDispatchGroup *group))action;
/// 任务单个异步任务完成 需要调用该方法
- (void)taskComplete;
/// 任务完成通知
- (void)groupNotify:(void(^)(void))action;
@end

NS_ASSUME_NONNULL_END


